package baidu.reader
{
    import baidu.reader.common.*;
    import baidu.reader.common.model.*;
    import baidu.ui.managers.*;
    
    import flash.display.*;
    import flash.events.*;
    
    import mx.core.UIComponent;

    public class ReaderMain extends UIComponent
    {
        private var core:IReaderCore;

        public function ReaderMain()
        {
            initParams();
            var tocData:TocDataModel = InstanceManager.createSingletonInstance(TocDataModel);
            tocData.getTocData();

            addEventListener(Event.ADDED_TO_STAGE, addToStageHandler);
        }

        private function addToStageHandler(event:Event) : void
        {
            initScreen();
            initCore();
        }

        private function initParams() : void
        {
            var appConfig:AppConfigModel = InstanceManager.createSingletonInstance(AppConfigModel);
            appConfig.loaderInfo = loaderInfo;
			
        }

        private function initScreen() : void
        {
            var screen:ScreenModel = InstanceManager.createSingletonInstance(ScreenModel);
            screen.stage = stage;
        }

        private function initCore() : void
        {
            core = CoreFactory.getCore(CoreTypes.TXT);
            core.init( stage);
        }

    }
}
